<script type="text/javascript">
function validateBook()
{
	
	var book_title = document.formBook.book_title.value;
	var book_author = document.formBook.book_author.value;
	var publisher = document.formBook.publisher.value;
	var edition = document.formBook.edition.value;
	var published_in = document.formBook.published_in.value;
	var isbn = document.formBook.isbn.value;
	var upload = document.formBook.upload.value;
	
	document.formBook.method = "post";
	document.formBook.action = "action_book.php";
	document.formBook.submit;
}
</script>
<?php
	$sql = "select `category`, `book_name`, `book_desc`, `author`, `ISBN`, `publisher`, 
			`edition`, `store_id`, `published_in`,`cover_image`,`price`,`active_status` from books where id='".$_GET['book_id']."'";
	$res = mysql_query($sql) or die(mysql_error()); 
	$data = mysql_fetch_array($res); 
 
  	if($data['active_status'] == "1")
	{
	  $active_status = "checked";
	}
	else {
	 $deactive_status = "checked";
	}
	
	if($_GET['book_id'] == "") {
		$process ="add";
	}
	else {
		$process ="edit";
	}
?>
<table border="0" width="100%" align="center">
<tr>
	<td width="46%" align="left"><span style="color:#1B78B7; font-size:14px; font-weight:bold">
    Add Books</span>&nbsp; 
	<!--<input type="button" name="addnew" value="Add New" onclick="return show();" />-->
	</td>
	<td width="40%" align="right" class="font12">
    <a href="index.php?tc=books_add" class="font12">Manage Books</a></td>
</tr>
<tr>
	<td background="images/topline.gif" colspan="3" height="11"></td>
</tr>    
</table>
<form name="formBook" onsubmit="return validateBook()" enctype="multipart/form-data">
<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%">
  <tbody><tr>
    <td align="right" width="21%" valign="middle" class="font12">Book Title</td>
    <td align="left" width="9%" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">
     <input type="text" style="width: 220px;" value="<?php echo $data['book_name'];?>" class="txtborder" id="book_title" name="book_title">
    </td>
  </tr>
  <tr>
    <td align="right" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" width="21%" valign="middle" class="font12">Book Author</td>
    <td align="left" width="9%" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">
     <input type="text" style="width: 220px;" value="<?php echo $data['author'];?>" class="txtborder" id="book_author" name="book_author">
    </td>
  </tr>
  <tr>
    <td align="right" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" width="21%" valign="middle" class="font12">Publisher</td>
    <td align="left" width="9%" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">
     <input type="text" style="width: 220px;" value="<?php echo $data['publisher'];?>" class="txtborder" id="publisher" name="publisher">
    </td>
  </tr>
  <tr>
    <td align="right" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="middle" class="font12">Edition</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">
    <input type="text" style="width: 220px;" value="<?php echo $data['edition'];?>" class="txtborder" id="edition" name="edition">
    </td>
  </tr>
  <tr>
    <td align="right" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="middle" class="font12">Price $</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">
    <input type="text" style="width: 220px;" value="<?php echo $data['price'];?>" class="txtborder" id="price" name="price">
    </td>
  </tr>
  <tr>
    <td align="right" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td align="right" valign="middle" class="font12">Published In</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">
    <input type="text" style="width: 220px;" value="<?php echo $data['published_in'];?>" class="txtborder" id="published_in" name="published_in">
    </td>
  </tr>
  <tr>
    <td align="right" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    </tr>
  <tr>
    <td align="right" valign="top" class="font12">Book Desc</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">
    <textarea class="txtborder" id="book_desc" name="book_desc" cols="50" rows="10"><?php echo $data['book_desc'];?></textarea>
    </td>
  </tr>
  <tr>
    <td align="right" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    </tr>
  <tr>
    <td align="right" valign="middle" class="font12">ISBN No.</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">
    <input type="text" style="width: 220px;" value="<?php echo $data['ISBN'];?>" class="txtborder" id="isbn" name="isbn">
    </td>
  </tr>
  <tr>
    <td align="right" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    </tr>
    <tr>
    <td align="right" valign="middle" class="font12">Cover Image</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">
    <input type="file" style="width: 220px;"  class="txtborder" id="upload" name="upload">
    <?php if($data['cover_image']!="") {?><img width="30px"  src="../uploads/books/<?php echo $data['cover_image'] ?>"/><?php } ?>
    
    </td>
    
  </tr>  
  <tr>
    <td align="right" valign="middle" class="font12">Status</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">
    <select class="txtborder" id="status" name="status">
    <option value="1" <?php echo $active_status;?>>Activate</option>
    <option value="0" <?php echo $deactive_status;?>>Deactivate</option>
    </select>
    </td>
  </tr>
  <tr>
    <td align="right" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">
    <input type="hidden" name="id" value="<?php echo $_GET['book_id'];?>">
     <input type="hidden" name="process" value="<?php echo $process;?>">
    <input type="submit" name="SubmitPhoto" value="Save"></td>
  </tr>
</tbody></table>
</form>